package com.ruoyi.electronicFence.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electronicFence.domain.TEfAreaEquipment;
import com.ruoyi.electronicFence.service.ITEfAreaEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场景- 与重要设备/重要场所关联管理
 *
 * @author sxygsj
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/electronicFence/equipment")
public class TEfAreaEquipmentController extends BaseController
{
    @Autowired
    private ITEfAreaEquipmentService tEfAreaEquipmentService;

    /**
     * 查询场景-设备/场所关联列表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TEfAreaEquipment tEfAreaEquipment)
    {
        startPage();
        List<TEfAreaEquipment> list = tEfAreaEquipmentService.selectTEfAreaEquipmentList(tEfAreaEquipment);
        return getDataTable(list);
    }

    /**
     * 导出场景-设备/场所关联列表
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:equipment:export')")
    @Log(title = "场景-设备/场所关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TEfAreaEquipment tEfAreaEquipment)
    {
        List<TEfAreaEquipment> list = tEfAreaEquipmentService.selectTEfAreaEquipmentList(tEfAreaEquipment);
        ExcelUtil<TEfAreaEquipment> util = new ExcelUtil<TEfAreaEquipment>(TEfAreaEquipment.class);
        util.exportExcel(response, list, "场景-设备/场所关联数据");
    }

    /**
     * 获取场景-设备/场所关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:equipment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tEfAreaEquipmentService.selectTEfAreaEquipmentById(id));
    }

    /**
     * 新增场景-设备/场所关联
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:equipment:add')")
    @Log(title = "场景-设备/场所关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TEfAreaEquipment tEfAreaEquipment)
    {
        return toAjax(tEfAreaEquipmentService.insertTEfAreaEquipment(tEfAreaEquipment));
    }

    /**
     * 修改场景-设备/场所关联
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:equipment:edit')")
    @Log(title = "场景-设备/场所关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TEfAreaEquipment tEfAreaEquipment)
    {
        return toAjax(tEfAreaEquipmentService.updateTEfAreaEquipment(tEfAreaEquipment));
    }

    /**
     * 删除场景-设备/场所关联
     */
    @PreAuthorize("@ss.hasPermi('electronicFence:equipment:remove')")
    @Log(title = "场景-设备/场所关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tEfAreaEquipmentService.deleteTEfAreaEquipmentByIds(ids));
    }
}
